//
//  ViewController.m
//  bezierPath
//
//  Created by Andrew on 2018/7/24.
//  Copyright © 2018年 Andrew. All rights reserved.
//

#import "ViewController.h"
#import "YMShowViewController.h"

@interface ViewController () <UITableViewDelegate,UITableViewDataSource>

/* 列表 */
@property (nonatomic, weak) UITableView *tableView;
/* 数据 */
@property (nonatomic, strong) NSMutableArray *datasource;

@end

@implementation ViewController


- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor whiteColor];
    
    [self setupView];
    
    [self setDatasource];
}

- (void)setDatasource
{
    NSArray *arr = @[
                     @"普通曲线",
                     @"二次曲线",
                     @"三次曲线",
                     @"动画帧",
                     @"心形动画"
                     ];
    
    [self.datasource addObjectsFromArray:arr];
    [self.tableView reloadData];
}

- (void)setupView
{
    UITableView *tableView = [[UITableView alloc] initWithFrame:self.view.bounds];
    tableView.delegate = self;
    tableView.dataSource = self;
    [self.view addSubview:tableView];
    
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.datasource.count;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 50;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *ID = @"cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if (!cell) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];
    }
    cell.textLabel.text = [NSString stringWithFormat:@"%@",self.datasource[indexPath.row]];
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    YMShowViewController *showVC = [[YMShowViewController alloc] init];
    showVC.indexPath = indexPath;
    [self.navigationController pushViewController:showVC animated:YES];
}

#pragma mark - 懒加载
- (NSMutableArray *)datasource
{
    if (!_datasource) {
        _datasource = [NSMutableArray new];
    }
    return _datasource;
}


@end
